package b4.view.component.pack
{
	import b4.config.BasicObjConfig;
	import b4.config.Config;
	import b4.model.vo.player.*;
	import b4.util.BFont;
	import b4.util.Resource;
	
	import flash.display.Sprite;
	import flash.filters.BitmapFilterQuality;
	import flash.filters.GlowFilter;
	import flash.text.*;
	
	
	public class BasicObjItem extends Sprite
	{
		public var obj:BasicObj;
		public var numTxt:TextField;
		private var num:int;
		
		public function BasicObjItem(obj:BasicObj)
		{
			super();
			this.obj = obj;
			var objConfig:BasicObjConfig = Config.objConfigs[obj.index];
			var ImgClass:Class = Resource.getClassByName(objConfig.iconImg);
			var imgSprite:Sprite = new ImgClass();
			imgSprite.width = 40;
			imgSprite.height = 40;
			numTxt = new TextField();
			numTxt.autoSize = TextFieldAutoSize.RIGHT;
        	numTxt.defaultTextFormat = new TextFormat(BFont.DEFAULT_FONT, 8, 0x000000, true);
        	numTxt.filters = [new GlowFilter(0xFFFFFF, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
        	numTxt.selectable = false;
			numTxt.x = 34;
			numTxt.y = 25;
			var object:Obj = obj as Obj;
			resetNum(object.num);
			addChild(imgSprite);
			addChild(numTxt);
		}
		
		public function setNumTxtState(visible:Boolean = true):void
		{
			numTxt.visible = visible;
		}
		
		public function resetNum(objNum:int):void
		{
			num = objNum;
			numTxt.text = num.toString(); 
		}
	}
}